package com.justgame.project.service.just.service.basic;

import com.justgame.project.service.just.entity.JustGameAddition;
import com.justgame.project.service.just.query.JustGameAdditionQuery;
import com.justgame.project.service.just.wrapper.JustGameAdditionWrapper;
import com.justgame.project.base.servcice.IBasicService;
import java.lang.Long;
import org.springframework.util.Assert;
import org.springframework.lang.NonNull;
import java.lang.String;

/**
 *
 * 游戏信息附加资源表服务自定义查询类
 *
 * @@tableName just_game_addition
 * @author Zwb
 */
@SuppressWarnings("all")
public interface BasicJustGameAdditionService extends IBasicService<JustGameAdditionQuery,JustGameAddition,JustGameAdditionWrapper> {

   /**
    * 新增创建
    * @param gameInfoId 游戏信息
    * @param type 类型
    * @param url 附加资源链接
    */
   default JustGameAddition baseAdd(Long gameInfoId, JustGameAddition.Type type, String url){
      JustGameAddition justGameAddition = new JustGameAddition();
      justGameAddition.setGameInfoId(safeValue(gameInfoId, null));
      justGameAddition.setType(safeValue(type, null));
      justGameAddition.setUrl(safeValue(url, null));
      save(justGameAddition);
      return justGameAddition;
   }

   /**
    * 更新
    * @param gameInfoId 游戏信息
    * @param type 类型
    * @param url 附加资源链接
    */
   default boolean baseUpdate(@NonNull JustGameAddition justGameAddition,Long gameInfoId, JustGameAddition.Type type, String url){
      Assert.notNull(url,"必须提供附加资源链接");
      Assert.notNull(type,"必须提供类型");
      Assert.notNull(gameInfoId,"必须提供游戏信息");
      Assert.notNull(justGameAddition.getId(),"必须提供主键ID");
      justGameAddition.setGameInfoId(safeValue(gameInfoId, null));
      justGameAddition.setType(safeValue(type, null));
      justGameAddition.setUrl(safeValue(url, null));
      return updateById(justGameAddition);
   }

}